<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<p id="old"></p>
		<p id="demo">点击按钮添加和删除元素</p>
		<button onabort="my()">点击</button>
	    <script>
	    	function my(){
	    		//获取p标签元素对象
	    		var old=document.getElementById('old');
	    		var mynew=document.getElementById('mynew');
	    		//定义数组
	    		var fruits=["banana","orange","apple","mango"];
	    		old.innerHTML=fruits;
	    		//在orange元素后添加元素：pear，pach
	    		/*fruits.splice(2,0,"pear","peach");
	    		mynew.innerHTML=fruits;*/
	    		//在orange元素后:删除两个元素
	    		fruits.splice(2,2);//删除的是否包含自己本身
	    		mynew.innerHTML=fruits;
	    		//设置p标签元素对象的内容
	    		
	    	}
	    </script>
	</body>
</html>
